#include <openssl/asn1.h>
#include <openssl/bio.h>
#include <openssl/evp.h>
#include <stdio.h>

int main() {
  // Convert integer to ASN1_INTEGER
  ASN1_INTEGER *asn1_int = ASN1_INTEGER_new();
  ASN1_INTEGER_set(asn1_int, 2022);//在这里修改

  // DER encode the integer
  unsigned char *der_bytes = NULL;
  int der_len = i2d_ASN1_INTEGER(asn1_int, &der_bytes);

  // Print the DER-encoded bytes
  printf("Integer (DER-encoded):\n");
  for (int i = 0; i < der_len; i++) {
    printf("%02X", der_bytes[i]);
  }
  printf("\n");

  // Free memory
  ASN1_INTEGER_free(asn1_int);
  OPENSSL_free(der_bytes);

  return 0;
}

